// SPDX-License-Identifier: Mulan PSL v2
/*
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * This software is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#[derive(Debug, Error)]
pub enum SerializeError {
    #[error("insufficient buffer capacity (required: {required}, capacity: {capacity})")]
    InsufficientBuffer { required: usize, capacity: usize },

    #[error("attempted to access null pointer")]
    NullPointer,

    #[error("argument size mitmatch (expected: {expected}, actual: {actual})")]
    SizeMismatch { expected: usize, actual: usize },

    #[error("argument size overflow")]
    SizeOverflow,

    #[error("alignment mismatch (expected: {expected}, actual: {actual})")]
    AlignmentMismatch { expected: usize, actual: usize },

    #[error("attempted to access unaligned data (type: {type_name}, alignment: {alignment})")]
    UnalignedAccess {
        type_name: &'static str,
        alignment: usize,
    },
}

mod argument;
pub use argument::*;

mod request;
pub use request::*;
use thiserror::Error;

#[cfg(test)]
mod tests;
